# =============================================================================
#'
#' @title Read Keyword
#'
#' @description Read keyword from GEOtop parameter file
#'
#' @details This function reads the values of a keyword from a GEOtop 
#' parameter file. If the keyword does not exist in the paremeter file
#' NA is returned.
#'
#' @param spath The simulation path. This is the directory that holds the 
#' GEOtop parameter file and that is passed to GEOtop upon execution.
#' @param keyword Name of the GEOtop keyword for which the value is read.
#" @param env List that passes a number of default settings.
#' @export
#' @examples
#' DtPlotPoint <- KeywordRead("./data", "DtPlotPoint", env = SetEnv())
#'
#' @return Returns the value of the keyword specified. This can be either a 
#' scalar or a vector and either numeric or string. If the keyword does not 
#' exist, NA is returned.  
#'
#' @author Stephan Gruber <stephan.gruber@@carleton.ca>
#'
# =============================================================================
KeywordRead <- function(spath, keyword, env = SetEnv()) { 
	#into file string
	fs <- readLines(file.path(spath, env$parfile)) 
	#line number
	line <- KeywordFindLine(fs, keyword, env = env) 
	#extract value
	return(KeywordReadLine(fs, line, env = env))
}